<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: container   Config.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">

	<div id="hd">
        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
        <h3>Container&nbsp; <span class="subtitle">2.3.1</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_container.html">container</a>
                
                 &gt; Config.js (source view) 
            </p>

	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form name="yui-classopts-form">
    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 #classopts { display:none; }
                        </style>
<div class="highlight" ><pre><span class="o">(</span><span class="k">function</span> <span class="o">()</span> <span class="o">{</span>

    <span class="c">/**</span>
<span class="c">    * Config is a utility used within an Object to allow the implementer to</span>
<span class="c">    * maintain a list of local configuration properties and listen for changes </span>
<span class="c">    * to those properties dynamically using CustomEvent. The initial values are </span>
<span class="c">    * also maintained so that the configuration can be reset at any given point </span>
<span class="c">    * to its initial state.</span>
<span class="c">    * @namespace YAHOO.util</span>
<span class="c">    * @class Config</span>
<span class="c">    * @constructor</span>
<span class="c">    * @param {Object} owner The owner Object to which this Config Object belongs</span>
<span class="c">    */</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Config</span> <span class="o">=</span> <span class="k">function</span> <span class="o">(</span><span class="nx">owner</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">if</span> <span class="o">(</span><span class="nx">owner</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">init</span><span class="o">(</span><span class="nx">owner</span><span class="o">);</span>
    
        <span class="o">}</span>
    
        <span class="k">if</span> <span class="o">(!</span><span class="nx">owner</span><span class="o">)</span> <span class="o">{</span> 
        
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;No owner specified for Config object&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">);</span> 
    
        <span class="o">}</span>
    
    <span class="o">};</span>


    <span class="k">var</span> <span class="nx">Lang</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">,</span>
        <span class="nx">CustomEvent</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">,</span>        
        <span class="nx">Config</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Config</span><span class="o">;</span>
    

    <span class="c">/**</span>
<span class="c">     * Constant representing the CustomEvent type for the config changed event.</span>
<span class="c">     * @property YAHOO.util.Config.CONFIG_CHANGED_EVENT</span>
<span class="c">     * @private</span>
<span class="c">     * @static</span>
<span class="c">     * @final</span>
<span class="c">     */</span>
    <span class="nx">Config</span><span class="o">.</span><span class="nx">CONFIG_CHANGED_EVENT</span> <span class="o">=</span> <span class="s2">&quot;configChanged&quot;</span><span class="o">;</span>
    
    <span class="c">/**</span>
<span class="c">     * Constant representing the boolean type string</span>
<span class="c">     * @property YAHOO.util.Config.BOOLEAN_TYPE</span>
<span class="c">     * @private</span>
<span class="c">     * @static</span>
<span class="c">     * @final</span>
<span class="c">     */</span>
    <span class="nx">Config</span><span class="o">.</span><span class="nx">BOOLEAN_TYPE</span> <span class="o">=</span> <span class="s2">&quot;boolean&quot;</span><span class="o">;</span>
    
    <span class="nx">Config</span><span class="o">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="o">{</span>
     
        <span class="c">/**</span>
<span class="c">        * Object reference to the owner of this Config Object</span>
<span class="c">        * @property owner</span>
<span class="c">        * @type Object</span>
<span class="c">        */</span>
        <span class="nx">owner</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        <span class="c">/**</span>
<span class="c">        * Boolean flag that specifies whether a queue is currently </span>
<span class="c">        * being executed</span>
<span class="c">        * @property queueInProgress</span>
<span class="c">        * @type Boolean</span>
<span class="c">        */</span>
        <span class="nx">queueInProgress</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
        
        <span class="c">/**</span>
<span class="c">        * Maintains the local collection of configuration property objects and </span>
<span class="c">        * their specified values</span>
<span class="c">        * @property config</span>
<span class="c">        * @private</span>
<span class="c">        * @type Object</span>
<span class="c">        */</span> 
        <span class="nx">config</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        <span class="c">/**</span>
<span class="c">        * Maintains the local collection of configuration property objects as </span>
<span class="c">        * they were initially applied.</span>
<span class="c">        * This object is used when resetting a property.</span>
<span class="c">        * @property initialConfig</span>
<span class="c">        * @private</span>
<span class="c">        * @type Object</span>
<span class="c">        */</span> 
        <span class="nx">initialConfig</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        <span class="c">/**</span>
<span class="c">        * Maintains the local, normalized CustomEvent queue</span>
<span class="c">        * @property eventQueue</span>
<span class="c">        * @private</span>
<span class="c">        * @type Object</span>
<span class="c">        */</span> 
        <span class="nx">eventQueue</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        
        <span class="c">/**</span>
<span class="c">        * Custom Event, notifying subscribers when Config properties are set </span>
<span class="c">        * (setProperty is called without the silent flag</span>
<span class="c">        * @event configChangedEvent</span>
<span class="c">        */</span>
        <span class="nx">configChangedEvent</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
    
        <span class="c">/**</span>
<span class="c">        * Initializes the configuration Object and all of its local members.</span>
<span class="c">        * @method init</span>
<span class="c">        * @param {Object} owner The owner Object to which this Config </span>
<span class="c">        * Object belongs</span>
<span class="c">        */</span>
        <span class="nx">init</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">owner</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">owner</span> <span class="o">=</span> <span class="nx">owner</span><span class="o">;</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">configChangedEvent</span> <span class="o">=</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="nx">Config</span><span class="o">.</span><span class="nx">CONFIG_CHANGED_EVENT</span><span class="o">);</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">configChangedEvent</span><span class="o">.</span><span class="nx">signature</span> <span class="o">=</span> <span class="nx">CustomEvent</span><span class="o">.</span><span class="nx">LIST</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">queueInProgress</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">config</span> <span class="o">=</span> <span class="o">{};</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">initialConfig</span> <span class="o">=</span> <span class="o">{};</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span> <span class="o">=</span> <span class="o">[];</span>
        
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Validates that the value passed in is a Boolean.</span>
<span class="c">        * @method checkBoolean</span>
<span class="c">        * @param {Object} val The value to validate</span>
<span class="c">        * @return {Boolean} true, if the value is valid</span>
<span class="c">        */</span> 
        <span class="nx">checkBoolean</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">val</span> <span class="o">==</span> <span class="nx">Config</span><span class="o">.</span><span class="nx">BOOLEAN_TYPE</span><span class="o">);</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Validates that the value passed in is a number.</span>
<span class="c">        * @method checkNumber</span>
<span class="c">        * @param {Object} val The value to validate</span>
<span class="c">        * @return {Boolean} true, if the value is valid</span>
<span class="c">        */</span>
        <span class="nx">checkNumber</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="o">(!</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">val</span><span class="o">));</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Fires a configuration property event using the specified value. </span>
<span class="c">        * @method fireEvent</span>
<span class="c">        * @private</span>
<span class="c">        * @param {String} key The configuration property&#39;s name</span>
<span class="c">        * @param {value} Object The value of the correct type for the property</span>
<span class="c">        */</span> 
        <span class="nx">fireEvent</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span> <span class="nx">key</span><span class="o">,</span> <span class="nx">value</span> <span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Firing Config event: &quot;</span> <span class="o">+</span> <span class="nx">key</span> <span class="o">+</span> <span class="s2">&quot;=&quot;</span> <span class="o">+</span> <span class="nx">value</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">);</span>
            <span class="k">var</span> <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">];</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">value</span><span class="o">);</span>
            <span class="o">}</span> 
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Adds a property to the Config Object&#39;s private config hash.</span>
<span class="c">        * @method addProperty</span>
<span class="c">        * @param {String} key The configuration property&#39;s name</span>
<span class="c">        * @param {Object} propertyObject The Object containing all of this </span>
<span class="c">        * property&#39;s arguments</span>
<span class="c">        */</span>
        <span class="nx">addProperty</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span> <span class="nx">key</span><span class="o">,</span> <span class="nx">propertyObject</span> <span class="o">)</span> <span class="o">{</span>
            <span class="nx">key</span> <span class="o">=</span> <span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Added property: &quot;</span> <span class="o">+</span> <span class="nx">key</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">);</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">]</span> <span class="o">=</span> <span class="nx">propertyObject</span><span class="o">;</span>
        
            <span class="nx">propertyObject</span><span class="o">.</span><span class="nx">event</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="o">{</span> <span class="nx">scope</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">owner</span> <span class="o">});</span>
            <span class="nx">propertyObject</span><span class="o">.</span><span class="nx">event</span><span class="o">.</span><span class="nx">signature</span> <span class="o">=</span> <span class="nx">CustomEvent</span><span class="o">.</span><span class="nx">LIST</span><span class="o">;</span>
            
            
            <span class="nx">propertyObject</span><span class="o">.</span><span class="nx">key</span> <span class="o">=</span> <span class="nx">key</span><span class="o">;</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="nx">propertyObject</span><span class="o">.</span><span class="nx">handler</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">propertyObject</span><span class="o">.</span><span class="nx">event</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="nx">propertyObject</span><span class="o">.</span><span class="nx">handler</span><span class="o">,</span> 
                    <span class="k">this</span><span class="o">.</span><span class="nx">owner</span><span class="o">);</span>
            <span class="o">}</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">propertyObject</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            
            <span class="k">if</span> <span class="o">(!</span> <span class="nx">propertyObject</span><span class="o">.</span><span class="nx">suppressEvent</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">queueProperty</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">propertyObject</span><span class="o">.</span><span class="nx">value</span><span class="o">);</span>
            <span class="o">}</span>
            
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Returns a key-value configuration map of the values currently set in  </span>
<span class="c">        * the Config Object.</span>
<span class="c">        * @method getConfig</span>
<span class="c">        * @return {Object} The current config, represented in a key-value map</span>
<span class="c">        */</span>
        <span class="nx">getConfig</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">cfg</span> <span class="o">=</span> <span class="o">{},</span>
                <span class="nx">prop</span><span class="o">,</span>
                <span class="nx">property</span><span class="o">;</span>
                
            <span class="k">for</span> <span class="o">(</span><span class="nx">prop</span> <span class="k">in</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">prop</span><span class="o">];</span>
                <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">cfg</span><span class="o">[</span><span class="nx">prop</span><span class="o">]</span> <span class="o">=</span> <span class="nx">property</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
            
            <span class="k">return</span> <span class="nx">cfg</span><span class="o">;</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Returns the value of specified property.</span>
<span class="c">        * @method getProperty</span>
<span class="c">        * @param {String} key The name of the property</span>
<span class="c">        * @return {Object}  The value of the specified property</span>
<span class="c">        */</span>
        <span class="nx">getProperty</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()];</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">property</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="k">return</span> <span class="kc">undefined</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Resets the specified property&#39;s value to its initial value.</span>
<span class="c">        * @method resetProperty</span>
<span class="c">        * @param {String} key The name of the property</span>
<span class="c">        * @return {Boolean} True is the property was reset, false if not</span>
<span class="c">        */</span>
        <span class="nx">resetProperty</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">key</span> <span class="o">=</span> <span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        
            <span class="k">var</span> <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">];</span>
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">initialConfig</span><span class="o">[</span><span class="nx">key</span><span class="o">]</span> <span class="o">&amp;&amp;</span> 
                    <span class="o">!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isUndefined</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">initialConfig</span><span class="o">[</span><span class="nx">key</span><span class="o">]))</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">initialConfig</span><span class="o">[</span><span class="nx">key</span><span class="o">]);</span>

                    <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
    
                <span class="o">}</span>
    
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
    
                <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
            <span class="o">}</span>
    
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Sets the value of a property. If the silent property is passed as </span>
<span class="c">        * true, the property&#39;s event will not be fired.</span>
<span class="c">        * @method setProperty</span>
<span class="c">        * @param {String} key The name of the property</span>
<span class="c">        * @param {String} value The value to set the property to</span>
<span class="c">        * @param {Boolean} silent Whether the value should be set silently, </span>
<span class="c">        * without firing the property event.</span>
<span class="c">        * @return {Boolean} True, if the set was successful, false if it failed.</span>
<span class="c">        */</span>
        <span class="nx">setProperty</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">value</span><span class="o">,</span> <span class="nx">silent</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">property</span><span class="o">;</span>
        
            <span class="nx">key</span> <span class="o">=</span> <span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;setProperty: &quot;</span> <span class="o">+</span> <span class="nx">key</span> <span class="o">+</span> <span class="s2">&quot;=&quot;</span> <span class="o">+</span> <span class="nx">value</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">);</span>
        
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">queueInProgress</span> <span class="o">&amp;&amp;</span> <span class="o">!</span> <span class="nx">silent</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// Currently running through a queue... </span>
<span class="c"></span>                <span class="k">this</span><span class="o">.</span><span class="nx">queueProperty</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span><span class="nx">value</span><span class="o">);</span>
                <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
    
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">];</span>
                <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">if</span> <span class="o">(</span><span class="nx">property</span><span class="o">.</span><span class="nx">validator</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">property</span><span class="o">.</span><span class="nx">validator</span><span class="o">(</span><span class="nx">value</span><span class="o">))</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
                    <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">property</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="o">;</span>
                        <span class="k">if</span> <span class="o">(!</span> <span class="nx">silent</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">value</span><span class="o">);</span>
                            <span class="k">this</span><span class="o">.</span><span class="nx">configChangedEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">([</span><span class="nx">key</span><span class="o">,</span> <span class="nx">value</span><span class="o">]);</span>
                        <span class="o">}</span>
                        <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="o">}</span>
                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                    <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Sets the value of a property and queues its event to execute. If the </span>
<span class="c">        * event is already scheduled to execute, it is</span>
<span class="c">        * moved from its current position to the end of the queue.</span>
<span class="c">        * @method queueProperty</span>
<span class="c">        * @param {String} key The name of the property</span>
<span class="c">        * @param {String} value The value to set the property to</span>
<span class="c">        * @return {Boolean}  true, if the set was successful, false if </span>
<span class="c">        * it failed.</span>
<span class="c">        */</span> 
        <span class="nx">queueProperty</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">value</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="nx">key</span> <span class="o">=</span> <span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;queueProperty: &quot;</span> <span class="o">+</span> <span class="nx">key</span> <span class="o">+</span> <span class="s2">&quot;=&quot;</span> <span class="o">+</span> <span class="nx">value</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">);</span>
        
            <span class="k">var</span> <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">],</span>
                <span class="nx">foundDuplicate</span> <span class="o">=</span> <span class="kc">false</span><span class="o">,</span>
                <span class="nx">iLen</span><span class="o">,</span>
                <span class="nx">queueItem</span><span class="o">,</span>
                <span class="nx">queueItemKey</span><span class="o">,</span>
                <span class="nx">queueItemValue</span><span class="o">,</span>
                <span class="nx">sLen</span><span class="o">,</span>
                <span class="nx">supercedesCheck</span><span class="o">,</span>
                <span class="nx">qLen</span><span class="o">,</span>
                <span class="nx">queueItemCheck</span><span class="o">,</span>
                <span class="nx">queueItemCheckKey</span><span class="o">,</span>
                <span class="nx">queueItemCheckValue</span><span class="o">,</span>
                <span class="nx">i</span><span class="o">,</span>
                <span class="nx">s</span><span class="o">,</span>
                <span class="nx">q</span><span class="o">;</span>
                                
            <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">if</span> <span class="o">(!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isUndefined</span><span class="o">(</span><span class="nx">value</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">validator</span> <span class="o">&amp;&amp;</span> 
                    <span class="o">!</span><span class="nx">property</span><span class="o">.</span><span class="nx">validator</span><span class="o">(</span><span class="nx">value</span><span class="o">))</span> <span class="o">{</span> <span class="c">// validator</span>
<span class="c"></span>                    <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
        
                    <span class="k">if</span> <span class="o">(!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isUndefined</span><span class="o">(</span><span class="nx">value</span><span class="o">))</span> <span class="o">{</span>
                        <span class="nx">property</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="o">;</span>
                    <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                        <span class="nx">value</span> <span class="o">=</span> <span class="nx">property</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
                    <span class="o">}</span>
        
                    <span class="nx">foundDuplicate</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
                    <span class="nx">iLen</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
        
                    <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">iLen</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="nx">queueItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
        
                        <span class="k">if</span> <span class="o">(</span><span class="nx">queueItem</span><span class="o">)</span> <span class="o">{</span>
                            <span class="nx">queueItemKey</span> <span class="o">=</span> <span class="nx">queueItem</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
                            <span class="nx">queueItemValue</span> <span class="o">=</span> <span class="nx">queueItem</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
                            
                            <span class="k">if</span> <span class="o">(</span><span class="nx">queueItemKey</span> <span class="o">==</span> <span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
    
                                <span class="c">/*</span>
<span class="c">                                    found a dupe... push to end of queue, null </span>
<span class="c">                                    current item, and break</span>
<span class="c">                                */</span>
    
                                <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    
                                <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span>
                                    <span class="o">[</span><span class="nx">key</span><span class="o">,</span> <span class="o">(!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isUndefined</span><span class="o">(</span><span class="nx">value</span><span class="o">)</span> <span class="o">?</span> 
                                    <span class="nx">value</span> <span class="o">:</span> <span class="nx">queueItemValue</span><span class="o">)]);</span>
    
                                <span class="nx">foundDuplicate</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                                <span class="k">break</span><span class="o">;</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                    
                    <span class="c">// this is a refire, or a new property in the queue</span>
<span class="c"></span>    
                    <span class="k">if</span> <span class="o">(!</span> <span class="nx">foundDuplicate</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isUndefined</span><span class="o">(</span><span class="nx">value</span><span class="o">))</span> <span class="o">{</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">.</span><span class="nx">push</span><span class="o">([</span><span class="nx">key</span><span class="o">,</span> <span class="nx">value</span><span class="o">]);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">property</span><span class="o">.</span><span class="nx">supercedes</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">sLen</span> <span class="o">=</span> <span class="nx">property</span><span class="o">.</span><span class="nx">supercedes</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
        
                    <span class="k">for</span> <span class="o">(</span><span class="nx">s</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">s</span> <span class="o">&lt;</span> <span class="nx">sLen</span><span class="o">;</span> <span class="nx">s</span><span class="o">++)</span> <span class="o">{</span>
        
                        <span class="nx">supercedesCheck</span> <span class="o">=</span> <span class="nx">property</span><span class="o">.</span><span class="nx">supercedes</span><span class="o">[</span><span class="nx">s</span><span class="o">];</span>
                        <span class="nx">qLen</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
        
                        <span class="k">for</span> <span class="o">(</span><span class="nx">q</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">q</span> <span class="o">&lt;</span> <span class="nx">qLen</span><span class="o">;</span> <span class="nx">q</span><span class="o">++)</span> <span class="o">{</span>
                            <span class="nx">queueItemCheck</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">[</span><span class="nx">q</span><span class="o">];</span>
        
                            <span class="k">if</span> <span class="o">(</span><span class="nx">queueItemCheck</span><span class="o">)</span> <span class="o">{</span>
                                <span class="nx">queueItemCheckKey</span> <span class="o">=</span> <span class="nx">queueItemCheck</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
                                <span class="nx">queueItemCheckValue</span> <span class="o">=</span> <span class="nx">queueItemCheck</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
                                
                                <span class="k">if</span> <span class="o">(</span><span class="nx">queueItemCheckKey</span> <span class="o">==</span> 
                                    <span class="nx">supercedesCheck</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">)</span> <span class="o">{</span>
    
                                    <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">.</span><span class="nx">push</span><span class="o">([</span><span class="nx">queueItemCheckKey</span><span class="o">,</span> 
                                        <span class="nx">queueItemCheckValue</span><span class="o">]);</span>
    
                                    <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">[</span><span class="nx">q</span><span class="o">]</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
                                    <span class="k">break</span><span class="o">;</span>
    
                                <span class="o">}</span>
                            <span class="o">}</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>

                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Config event queue: &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">outputEventQueue</span><span class="o">(),</span> <span class="s2">&quot;info&quot;</span><span class="o">);</span>
        
                <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Fires the event for a property using the property&#39;s current value.</span>
<span class="c">        * @method refireEvent</span>
<span class="c">        * @param {String} key The name of the property</span>
<span class="c">        */</span>
        <span class="nx">refireEvent</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">key</span> <span class="o">=</span> <span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        
            <span class="k">var</span> <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">];</span>
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span> <span class="o">&amp;&amp;</span> 
    
                <span class="o">!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isUndefined</span><span class="o">(</span><span class="nx">property</span><span class="o">.</span><span class="nx">value</span><span class="o">))</span> <span class="o">{</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">queueInProgress</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">queueProperty</span><span class="o">(</span><span class="nx">key</span><span class="o">);</span>
    
                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">property</span><span class="o">.</span><span class="nx">value</span><span class="o">);</span>
    
                <span class="o">}</span>
    
            <span class="o">}</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Applies a key-value Object literal to the configuration, replacing  </span>
<span class="c">        * any existing values, and queueing the property events.</span>
<span class="c">        * Although the values will be set, fireQueue() must be called for their </span>
<span class="c">        * associated events to execute.</span>
<span class="c">        * @method applyConfig</span>
<span class="c">        * @param {Object} userConfig The configuration Object literal</span>
<span class="c">        * @param {Boolean} init  When set to true, the initialConfig will </span>
<span class="c">        * be set to the userConfig passed in, so that calling a reset will </span>
<span class="c">        * reset the properties to the passed values.</span>
<span class="c">        */</span>
        <span class="nx">applyConfig</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">userConfig</span><span class="o">,</span> <span class="nx">init</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">sKey</span><span class="o">,</span>
                <span class="nx">oValue</span><span class="o">,</span>
                <span class="nx">oConfig</span><span class="o">;</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">init</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oConfig</span> <span class="o">=</span> <span class="o">{};</span>

                <span class="k">for</span> <span class="o">(</span><span class="nx">sKey</span> <span class="k">in</span> <span class="nx">userConfig</span><span class="o">)</span> <span class="o">{</span>
                
                    <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">userConfig</span><span class="o">,</span> <span class="nx">sKey</span><span class="o">))</span> <span class="o">{</span>

                        <span class="nx">oConfig</span><span class="o">[</span><span class="nx">sKey</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()]</span> <span class="o">=</span> <span class="nx">userConfig</span><span class="o">[</span><span class="nx">sKey</span><span class="o">];</span>

                    <span class="o">}</span>
                
                <span class="o">}</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">initialConfig</span> <span class="o">=</span> <span class="nx">oConfig</span><span class="o">;</span>

            <span class="o">}</span>

            <span class="k">for</span> <span class="o">(</span><span class="nx">sKey</span> <span class="k">in</span> <span class="nx">userConfig</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">userConfig</span><span class="o">,</span> <span class="nx">sKey</span><span class="o">))</span> <span class="o">{</span>
            
                    <span class="k">this</span><span class="o">.</span><span class="nx">queueProperty</span><span class="o">(</span><span class="nx">sKey</span><span class="o">,</span> <span class="nx">userConfig</span><span class="o">[</span><span class="nx">sKey</span><span class="o">]);</span>
                
                <span class="o">}</span>

            <span class="o">}</span>

        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Refires the events for all configuration properties using their </span>
<span class="c">        * current values.</span>
<span class="c">        * @method refresh</span>
<span class="c">        */</span>
        <span class="nx">refresh</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">prop</span><span class="o">;</span>
        
            <span class="k">for</span> <span class="o">(</span><span class="nx">prop</span> <span class="k">in</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">refireEvent</span><span class="o">(</span><span class="nx">prop</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Fires the normalized list of queued property change events</span>
<span class="c">        * @method fireQueue</span>
<span class="c">        */</span>
        <span class="nx">fireQueue</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">i</span><span class="o">,</span> 
                <span class="nx">queueItem</span><span class="o">,</span>
                <span class="nx">key</span><span class="o">,</span>
                <span class="nx">value</span><span class="o">,</span>
                <span class="nx">property</span><span class="o">;</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">queueInProgress</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span><span class="nx">i</span> <span class="o">&lt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="nx">queueItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="k">if</span> <span class="o">(</span><span class="nx">queueItem</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="nx">key</span> <span class="o">=</span> <span class="nx">queueItem</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
                    <span class="nx">value</span> <span class="o">=</span> <span class="nx">queueItem</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
                    <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">];</span>
        
                    <span class="nx">property</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="o">;</span>
        
                    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span><span class="nx">value</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">queueInProgress</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span> <span class="o">=</span> <span class="o">[];</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Subscribes an external handler to the change event for any </span>
<span class="c">        * given property. </span>
<span class="c">        * @method subscribeToConfigEvent</span>
<span class="c">        * @param {String} key The property name</span>
<span class="c">        * @param {Function} handler The handler function to use subscribe to </span>
<span class="c">        * the property&#39;s event</span>
<span class="c">        * @param {Object} obj The Object to use for scoping the event handler </span>
<span class="c">        * (see CustomEvent documentation)</span>
<span class="c">        * @param {Boolean} override Optional. If true, will override &quot;this&quot;  </span>
<span class="c">        * within the handler to map to the scope Object passed into the method.</span>
<span class="c">        * @return {Boolean} True, if the subscription was successful, </span>
<span class="c">        * otherwise false.</span>
<span class="c">        */</span> 
        <span class="nx">subscribeToConfigEvent</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">handler</span><span class="o">,</span> <span class="nx">obj</span><span class="o">,</span> <span class="nx">override</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()];</span>
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">if</span> <span class="o">(!</span><span class="nx">Config</span><span class="o">.</span><span class="nx">alreadySubscribed</span><span class="o">(</span><span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">,</span> <span class="nx">handler</span><span class="o">,</span> <span class="nx">obj</span><span class="o">))</span> <span class="o">{</span>
    
                    <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="nx">handler</span><span class="o">,</span> <span class="nx">obj</span><span class="o">,</span> <span class="nx">override</span><span class="o">);</span>
    
                <span class="o">}</span>
    
                <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
    
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
    
                <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    
            <span class="o">}</span>
    
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Unsubscribes an external handler from the change event for any </span>
<span class="c">        * given property. </span>
<span class="c">        * @method unsubscribeFromConfigEvent</span>
<span class="c">        * @param {String} key The property name</span>
<span class="c">        * @param {Function} handler The handler function to use subscribe to </span>
<span class="c">        * the property&#39;s event</span>
<span class="c">        * @param {Object} obj The Object to use for scoping the event </span>
<span class="c">        * handler (see CustomEvent documentation)</span>
<span class="c">        * @return {Boolean} True, if the unsubscription was successful, </span>
<span class="c">        * otherwise false.</span>
<span class="c">        */</span>
        <span class="nx">unsubscribeFromConfigEvent</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">handler</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">property</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">[</span><span class="nx">key</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()];</span>
            <span class="k">if</span> <span class="o">(</span><span class="nx">property</span> <span class="o">&amp;&amp;</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">return</span> <span class="nx">property</span><span class="o">.</span><span class="nx">event</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">(</span><span class="nx">handler</span><span class="o">,</span> <span class="nx">obj</span><span class="o">);</span>
            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Returns a string representation of the Config object</span>
<span class="c">        * @method toString</span>
<span class="c">        * @return {String} The Config object in string format.</span>
<span class="c">        */</span>
        <span class="nx">toString</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">output</span> <span class="o">=</span> <span class="s2">&quot;Config&quot;</span><span class="o">;</span>
            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">owner</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">output</span> <span class="o">+=</span> <span class="s2">&quot; [&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">owner</span><span class="o">.</span><span class="nx">toString</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot;]&quot;</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">return</span> <span class="nx">output</span><span class="o">;</span>
        <span class="o">},</span>
        
        <span class="c">/**</span>
<span class="c">        * Returns a string representation of the Config object&#39;s current </span>
<span class="c">        * CustomEvent queue</span>
<span class="c">        * @method outputEventQueue</span>
<span class="c">        * @return {String} The string list of CustomEvents currently queued </span>
<span class="c">        * for execution</span>
<span class="c">        */</span>
        <span class="nx">outputEventQueue</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">output</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">,</span>
                <span class="nx">queueItem</span><span class="o">,</span>
                <span class="nx">q</span><span class="o">,</span>
                <span class="nx">nQueue</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
              
            <span class="k">for</span> <span class="o">(</span><span class="nx">q</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">q</span> <span class="o">&lt;</span> <span class="nx">nQueue</span><span class="o">;</span> <span class="nx">q</span><span class="o">++)</span> <span class="o">{</span>
                <span class="nx">queueItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span><span class="o">[</span><span class="nx">q</span><span class="o">];</span>
                <span class="k">if</span> <span class="o">(</span><span class="nx">queueItem</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">output</span> <span class="o">+=</span> <span class="nx">queueItem</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">+</span> <span class="s2">&quot;=&quot;</span> <span class="o">+</span> <span class="nx">queueItem</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="k">return</span> <span class="nx">output</span><span class="o">;</span>
        <span class="o">},</span>

        <span class="c">/**</span>
<span class="c">        * Sets all properties to null, unsubscribes all listeners from each </span>
<span class="c">        * property&#39;s change event and all listeners from the configChangedEvent.</span>
<span class="c">        * @method destroy</span>
<span class="c">        */</span>
        <span class="nx">destroy</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">config</span><span class="o">,</span>
                <span class="nx">sProperty</span><span class="o">,</span>
                <span class="nx">oProperty</span><span class="o">;</span>


            <span class="k">for</span> <span class="o">(</span><span class="nx">sProperty</span> <span class="k">in</span> <span class="nx">oConfig</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="k">if</span> <span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="nx">oConfig</span><span class="o">,</span> <span class="nx">sProperty</span><span class="o">))</span> <span class="o">{</span>

                    <span class="nx">oProperty</span> <span class="o">=</span> <span class="nx">oConfig</span><span class="o">[</span><span class="nx">sProperty</span><span class="o">];</span>

                    <span class="nx">oProperty</span><span class="o">.</span><span class="nx">event</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
                    <span class="nx">oProperty</span><span class="o">.</span><span class="nx">event</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

                <span class="o">}</span>
            
            <span class="o">}</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">configChangedEvent</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">();</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">configChangedEvent</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">owner</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">config</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">initialConfig</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">eventQueue</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        
        <span class="o">}</span>

    <span class="o">};</span>
    
    
    
    <span class="c">/**</span>
<span class="c">    * Checks to determine if a particular function/Object pair are already </span>
<span class="c">    * subscribed to the specified CustomEvent</span>
<span class="c">    * @method YAHOO.util.Config.alreadySubscribed</span>
<span class="c">    * @static</span>
<span class="c">    * @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check </span>
<span class="c">    * the subscriptions</span>
<span class="c">    * @param {Function} fn The function to look for in the subscribers list</span>
<span class="c">    * @param {Object} obj The execution scope Object for the subscription</span>
<span class="c">    * @return {Boolean} true, if the function/Object pair is already subscribed </span>
<span class="c">    * to the CustomEvent passed in</span>
<span class="c">    */</span>
    <span class="nx">Config</span><span class="o">.</span><span class="nx">alreadySubscribed</span> <span class="o">=</span> <span class="k">function</span> <span class="o">(</span><span class="nx">evt</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">nSubscribers</span> <span class="o">=</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">subscribers</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
            <span class="nx">subsc</span><span class="o">,</span>
            <span class="nx">i</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">nSubscribers</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">i</span> <span class="o">=</span> <span class="nx">nSubscribers</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
        
            <span class="k">do</span> <span class="o">{</span>

                <span class="nx">subsc</span> <span class="o">=</span> <span class="nx">evt</span><span class="o">.</span><span class="nx">subscribers</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

                <span class="k">if</span> <span class="o">(</span><span class="nx">subsc</span> <span class="o">&amp;&amp;</span> <span class="nx">subsc</span><span class="o">.</span><span class="nx">obj</span> <span class="o">==</span> <span class="nx">obj</span> <span class="o">&amp;&amp;</span> <span class="nx">subsc</span><span class="o">.</span><span class="nx">fn</span> <span class="o">==</span> <span class="nx">fn</span><span class="o">)</span> <span class="o">{</span>
        
                    <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
        
                <span class="o">}</span>    
            
            <span class="o">}</span>
            <span class="k">while</span> <span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
        
        <span class="o">}</span>
    
        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    
    <span class="o">};</span>
    
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">augmentProto</span><span class="o">(</span><span class="nx">Config</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">EventProvider</span><span class="o">);</span>

<span class="o">}());</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_colorpicker.html">colorpicker</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class="selected"><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_editor.html">editor</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_imageloader.html">imageloader</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>

                                <li class=""><a href="module_yuiloader.html">yuiloader</a></li>

                                <li class=""><a href="module_yuitest.html">yuitest</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.util.Config.html">YAHOO.util.Config</a></li>
                                <li class=""><a href="YAHOO.widget.ContainerEffect.html">YAHOO.widget.ContainerEffect</a></li>
                                <li class=""><a href="YAHOO.widget.Dialog.html">YAHOO.widget.Dialog</a></li>
                                <li class=""><a href="YAHOO.widget.Module.html">YAHOO.widget.Module</a></li>
                                <li class=""><a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a></li>
                                <li class=""><a href="YAHOO.widget.OverlayManager.html">YAHOO.widget.OverlayManager</a></li>
                                <li class=""><a href="YAHOO.widget.Panel.html">YAHOO.widget.Panel</a></li>
                                <li class=""><a href="YAHOO.widget.SimpleDialog.html">YAHOO.widget.SimpleDialog</a></li>
                                <li class=""><a href="YAHOO.widget.Tooltip.html">YAHOO.widget.Tooltip</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="Config.js.html">Config.js</a></li>
                                <li class=""><a href="ContainerEffect.js.html">ContainerEffect.js</a></li>
                                <li class=""><a href="Dialog.js.html">Dialog.js</a></li>
                                <li class=""><a href="Module.js.html">Module.js</a></li>
                                <li class=""><a href="Overlay.js.html">Overlay.js</a></li>
                                <li class=""><a href="OverlayManager.js.html">OverlayManager.js</a></li>
                                <li class=""><a href="Panel.js.html">Panel.js</a></li>
                                <li class=""><a href="SimpleDialog.js.html">SimpleDialog.js</a></li>
                                <li class=""><a href="Tooltip.js.html">Tooltip.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
